//
//  PTRecorderLessonTextController.m
//  PocketTutor
//
//  Created by yate1996 on 15/6/10.
//  Copyright (c) 2015年 yate1996. All rights reserved.
//

#import "PTRecorderLessonTextController.h"
#import "Header.h"

@interface PTRecorderLessonTextController ()
@property (nonatomic, strong) UILabel *lessonText;
@property (nonatomic, strong) UIImageView *lessonTextImage;
@end

@implementation PTRecorderLessonTextController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = PTColor(244, 244, 244, 1);
    self.title = @"Textbook";

    [self setupLessonText];
    [self setupLessonTextFrame];
}


-(void)setupLessonText
{
    NSMutableDictionary *textAttr = [NSMutableDictionary dictionary];
    textAttr[NSFontAttributeName] = PTHelveticaNeueLight12;
    UILabel *lessonText = [[UILabel alloc]init];
    lessonText.text = @"如果你无法简洁的表达你的想法，那只说明你还不够了解它。\n--阿尔伯特-爱因斯坦";
    [self.view addSubview:lessonText];
    self.lessonText = lessonText;
    lessonText.numberOfLines = 0;
    self.lessonText.font = PTHelveticaNeueLight12;
    
    UIImageView *lessonTextImage = [[UIImageView alloc]init];
    lessonTextImage.image = [UIImage imageNamed:@"minion_01"];
    [self.view addSubview:lessonTextImage];
    self.lessonTextImage = lessonTextImage;
}



-(void)setupLessonTextFrame
{
    
    CGFloat lessonTextX = PTRecorderCellInset;
    CGFloat lessonTextY = 2 * PTRecorderCellInset + 64;
    NSMutableDictionary *textAttr = [NSMutableDictionary dictionary];
    textAttr[NSFontAttributeName] = PTHelveticaNeueLight12;
    CGSize titleSize = [self.lessonText.text boundingRectWithSize:CGSizeMake(320, 0) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:textAttr context:nil].size;
    self.lessonText.frame  = (CGRect){{lessonTextX,lessonTextY},titleSize};
    

    CGFloat lessonTextImageX = lessonTextX;
    CGFloat lessonTextImageY = CGRectGetMaxY(self.lessonText.frame)+ 3 * PTRecorderCellMargin;
    self.lessonTextImage.frame = (CGRect){{lessonTextImageX,lessonTextImageY},titleSize.width,self.lessonTextImage.image.size.height};
    
    
    
}


@end
